/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Winner
 */
@Entity
@Table(name = "tblComplaint")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblComplaint.findAll", query = "SELECT t FROM TblComplaint t"),
    @NamedQuery(name = "TblComplaint.findByCpID", query = "SELECT t FROM TblComplaint t WHERE t.cpID = :cpID"),
    @NamedQuery(name = "TblComplaint.findByCpDescription", query = "SELECT t FROM TblComplaint t WHERE t.cpDescription = :cpDescription"),
    @NamedQuery(name = "TblComplaint.findByCpStatus", query = "SELECT t FROM TblComplaint t WHERE t.cpStatus = :cpStatus"),
    @NamedQuery(name = "TblComplaint.findByCpCreated", query = "SELECT t FROM TblComplaint t WHERE t.cpCreated = :cpCreated"),
    @NamedQuery(name = "TblComplaint.findByCpAdjustmented", query = "SELECT t FROM TblComplaint t WHERE t.cpAdjustmented = :cpAdjustmented"),
    @NamedQuery(name = "TblComplaint.findByDateCpCreated", query = "SELECT t FROM TblComplaint t WHERE t.cpCreated >= :dateStart AND t.cpCreated <= :dateEnd ORDER BY t.cpCreated DESC"),
    @NamedQuery(name = "TblComplaint.findByDateCpAdjustmented", query = "SELECT t FROM TblComplaint t WHERE t.cpAdjustmented >= :dateStart AND t.cpAdjustmented <= :dateEnd ORDER BY t.cpAdjustmented DESC"),
    @NamedQuery(name = "TblComplaint.findByOrderHasManyComplaint", query = "SELECT t.odID as order_ID,count(t.odID) as counter FROM TblComplaint t Group By t.odID ORDER By 1")})
public class TblComplaint implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "cpID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer cpID;
    @Size(max = 1073741823)
    @Column(name = "cpDescription")
    private String cpDescription;
    @Column(name = "cpStatus")
    private Boolean cpStatus;
    @Basic(optional = false)
    @NotNull

    @Column(name = "cpCreated")
    @Temporal(TemporalType.TIMESTAMP)
    private Date cpCreated;

    @Column(name = "cpAdjustmented")
    @Temporal(TemporalType.TIMESTAMP)
    private Date cpAdjustmented;
    @JoinColumn(name = "usID", referencedColumnName = "usID")
    @ManyToOne
    private TblUser usID;
    @JoinColumn(name = "odID", referencedColumnName = "odID")
    @ManyToOne
    private TblOrder odID;
    @JoinColumn(name = "mnID", referencedColumnName = "mnID")
    @ManyToOne
    private TblManager mnID;

    public TblComplaint() {
    }

    public TblComplaint(Integer cpID) {
        this.cpID = cpID;
    }

    public TblComplaint(Integer cpID, Date cpCreated) {
        this.cpID = cpID;
        this.cpCreated = cpCreated;
    }

    public Integer getCpID() {
        return cpID;
    }

    public void setCpID(Integer cpID) {
        this.cpID = cpID;
    }

    public String getCpDescription() {
        return cpDescription;
    }

    public void setCpDescription(String cpDescription) {
        this.cpDescription = cpDescription;
    }

    public Boolean getCpStatus() {
        return cpStatus;
    }

    public void setCpStatus(Boolean cpStatus) {
        this.cpStatus = cpStatus;
    }

    public Date getCpCreated() {
        return cpCreated;
    }

    public void setCpCreated(Date cpCreated) {
        this.cpCreated = cpCreated;
    }

    public Date getCpAdjustmented() {
        return cpAdjustmented;
    }

    public void setCpAdjustmented(Date cpAdjustmented) {
        this.cpAdjustmented = cpAdjustmented;
    }

    public TblUser getUsID() {
        return usID;
    }

    public void setUsID(TblUser usID) {
        this.usID = usID;
    }

    public TblOrder getOdID() {
        return odID;
    }

    public void setOdID(TblOrder odID) {
        this.odID = odID;
    }

    public TblManager getMnID() {
        return mnID;
    }

    public void setMnID(TblManager mnID) {
        this.mnID = mnID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cpID != null ? cpID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblComplaint)) {
            return false;
        }
        TblComplaint other = (TblComplaint) object;
        if ((this.cpID == null && other.cpID != null) || (this.cpID != null && !this.cpID.equals(other.cpID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aptech.entities.TblComplaint[ cpID=" + cpID + " ]";
    }
}
